package com.example.tellwin.mine.presenter;

import com.example.tellwin.api.TwjfApi;
import com.example.tellwin.base.RxPresenter;
import com.example.tellwin.base.SimpleCallback;
import com.example.tellwin.home.bean.ContentBean;
import com.example.tellwin.mine.contract.ApplyResultContract;
import com.example.tellwin.mine.contract.WithdrawMoneyContract;
import com.example.tellwin.utils.HttpUtils;

import javax.inject.Inject;

import okhttp3.RequestBody;

/**
 * @author : LinZePeng
 * @date : 2020/12/1
 * @Describe ：
 **/
public class WithdrawMoneyPresenter extends RxPresenter<WithdrawMoneyContract.View> implements WithdrawMoneyContract.Presenter<WithdrawMoneyContract.View> {

    private TwjfApi mApi;

    @Inject
    public WithdrawMoneyPresenter(TwjfApi mApi) {
        this.mApi = mApi;
    }

    @Override
    public void withDrawal(String money, int type) {
        RequestBody requestBody = HttpUtils.getRequestBody("money" , money , "withdrawalType" , type+"");
        mApi.withDrawal(requestBody , new SimpleCallback<ContentBean>(mView) {
            @Override
            public void onSuccess(ContentBean contentBean) {
                mView.withDrawalSuccess();
            }

            @Override
            public void onFail(String msg) {

            }
        });
    }

    @Override
    public void getWithDrawalHint() {
        mApi.getWithDrawalHint( new SimpleCallback<ContentBean>(mView) {
            @Override
            public void onSuccess(ContentBean contentBean) {
                mView.gwithDrawalHint(contentBean.getWithdrawalExplain());
            }

            @Override
            public void onFail(String msg) {

            }
        });
    }
}
